This invention relates to a method and apparatus for encoding digital signal data obtained on digitizing speech or audio signals or video signals, and a data recording medium having encoded data recorded thereon.
In compressing data at a pre-set bit rate (the number of bits per unit time) for recording or transmission, it is necessary to calculate the number of bits required for encoding before actually proceeding to encoding. The number of bits may be obtained by calculating the sum of the number of bits required for respective words.
In general audio signal compression techniques, it is determined by which number of bits or steps the respective signal components of the input signal are to be quantized, and quantization is effectuated with the number of quantization bits thus determined or with the number of quantization steps thus determined in order to encode the quantized words.
With fixed-length encoding, the number of bits required for encoding may be determined only with the number of bits or with the number of quantization steps, so that the number of bits required for encoding may be determined without effectuating the quantization.
Conversely, with variable length encoding, the number of bits required for encoding is changed depending on the value of the quantized words, even if the word has been quantized with the same number of quantization bits or the same number of quantization steps. Thus the number of bits required for encoding cannot be known unless the quantization is effectuated.
FIG. 1 is a flow chart showing the process of calculating the sum of the numbers of bits in the variable length encoding.
In FIG. 1, the number of bits Allbits required for encoding an input data string Data[i] is calculated. The number of data in the data string is Ndata. The number of bits or the number of quantization steps are assumed to be pre-set.
At step S10, the loop control variable i used for the series of operations and the variable Allbits indicating the total number of bits are initialized, that is set to zero.
At the next step S11, the ith data Data[i] is normalized, using a normalizing coefficient, in order to calculate a normalized value D. The function Normalize() executes normalization in accordance with a pre-set normalization coefficient.
At the next step S12, the normalized value is actually quantized. The function Quantize() effectuates quantization in accordance with the pre-set number of quantization bits or the pre-set number of quantization steps and returns the as-quantized values (integers).
At the next step S13, the number of bits required for encoding the quantized value Q Length[i] is found. The function LenOVal() is responsive to the as-quantized value to return the number of bits required for encoding.
At the next step S14, the number of encoding bits Length[i] of the as-quantized value Q is cumulatively added to the variable Allbits indicating the total number of bits in order to calculate the sum of the numbers of bits required for encoding.
At the next step S15, i is incremented for having reference to the next data.
At the next step S16, it is determined whether or not processing has been completed for all of the data Data[i]. If the result is YES, the program is terminated. If otherwise, the program reverts to step S11 in order to process the next data.
With the variable length encoding, since it becomes necessary to quantize the respective input data in order to calculate the total number of bits required for encoding, the quantity of the arithmetic/logical operations becomes voluminous.